package com.commute.schedule;

import java.util.Date;
import java.util.LinkedList;

/*
 * A Schedule was originally thought to include more information
 * specific to a schedule (such as latitude, longitude etc) 
 * and could be extended to do so. Currently it only holds activities
 * since these themselves know latitude and longitude. 
 * 
 * What it does do is know how to provide the next activity
 * based on current time.  
 */
public class Schedule {
	
	LinkedList<Activity> activities;
	
	public Schedule(String filePath, double lat, double lon) {
		Parser parser = new Parser();
		activities = parser.parseICSFile(filePath, lat, lon);
	}

	public Activity nextActivity(){
		Date currentTime = new Date();
		Activity returnActivity = null;
		for (Activity activity : activities) {
			if(activity.start.after(currentTime)){
				returnActivity = activity;
				break;
			}
		}
		
		if(returnActivity==null)
			System.out.println("There are no future activities in this Schedule, please provide a new schedule or modify the current one for testing.");
		
		return returnActivity;
	}
	
	
//	public static void main(String[] args) {
//		Schedule s = new Schedule("/Users/hedenberg/Documents/Universitet/M7012E/m7012e/M7012E.ics", 1, 2);
//		System.out.println("Next: "+s.nextActivity().lon());
//	}

}
